import QtQuick 2.7
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3

Popup{
    id: dialog
    implicitWidth:200
    implicitHeight: 200

    MouseArea {
        anchors.fill: parent
        property point clickPos: "0,0"
        acceptedButtons: Qt.LeftButton
        onPressed: {
            clickPos  = Qt.point(mouse.x,mouse.y)
        }
        onPositionChanged: {
            var delta = Qt.point(mouse.x-clickPos.x, mouse.y-clickPos.y)
            dialog.x = dialog.x+delta.x
            dialog.y = dialog.y+delta.y
        }
    }


    property alias label:describe.text


    modal:true
    dim:true
    closePolicy:Popup.CloseOnEscape


    Label{
        id:describe
        font.pixelSize: 22
        anchors.centerIn: parent
    }

    PropertyAnimation{
        id: hideAnimation
        target: dialog
        properties:"opacity"
        from: 1.0
        to: 0.0
        duration: 500

        onStopped: {
            dialog.close()
        }
    }

    PropertyAnimation{
        id: showAnimation
        target: dialog
        properties:"opacity"
        from: 0.0
        to: 1.0
        duration: 300
    }

    function popClose(){
        hideAnimation.running = true
    }

    Timer{
        id:timer
        interval: 3000; running: false; repeat: false
        onTriggered: {
            timer.stop()
            dialog.close()
        }
    }

    onOpened: {
        timer.start()
    }


}
